function [ obj ] = obj( theta,beta,delta,r,lambda,V,U, tau,W)
%This function computes the sum of squared difference between observed and
%predicted prices using weights W
n = length(lambda);
gamma = theta(1:n);
c = theta(n+1);
t1 = (1-gamma)./(1-beta.*delta.*(1-gamma.*lambda));
t1 = t1.*(beta.*delta.*c+(1-beta.*delta).*r);

t2 = gamma.*(1-beta.*delta.*(1-lambda))./(1-beta.*delta.*(1-gamma.*lambda));
t2 = t2.*(U-V);


obj = (tau-t1-t2);
obj = obj.^2;
obj = W.*obj;
obj = nansum(obj(:));

end


